import React from 'react'
// ===================================================================== 
const { $Lazy } = window
// ===================================================================== Lazy
const Button 		= $Lazy.load(()=>import('@antd/button'))
const Switch 		= $Lazy.load(()=>import('@antd/form/switch'))
const Checkbox 		= $Lazy.load(()=>import('@antd/form/checkbox'))
const Upload   		= $Lazy.hook(()=>import('@antd/upload'))
const Popconfirm   	= $Lazy.load(()=>import('@antd/popconfirm'))
const Printer   	= $Lazy.hook(()=>import('#private/printer'))
// const ImportFile 	= $Lazy.load(()=>import('#private/common/import'))
// =====================================================================
const Index = ({ controls }) => (
	<>
		{
			window.$fn.hasArray(controls) && controls.map((v,i)=>{
				return  !window.$fn.hasObject(v) || v.hide ? null : (
					<span className='x-btns' key={i}>
						{
							v.type === 'switch' && <Switch {...v}  />
						}
						{
							v.type === 'checkbox' && <Checkbox { ...v}  />
						}
						{
							v.type === 'upload' && <Upload mode='button' btnText={v.title} btnConfig={{size:'small'}}  { ...v}  />
						}
						{
							v.type === 'del' && <Popconfirm { ...v}  />
						}
						{
							v.type === 'printer' && <Printer { ...v}  />
						}
						{
							!v.type && <Button {...v}/>
						}
					</span>
				)
			})
		}
	</>
)
export default Index